package chapter14.section2;

/**
 * 程序14-6a：Transaction 添加了供表格显示列名的内容和利用下标访问对象数据的方法，其余的每个属性
 * 的getter和setter方法需要读者自己添加
 */
public class Transaction {
    // 此数组用于提供表格的列名
    public static final String[] columnModel = {"账号", "交易类型", "交易金额", "交易后余额", "交易时间", "交易状态"};
    private final String account;
    private final String type;// 业务类型
    private final double amount;// 交易金额
    private final double balance;// 交易后的余额
    private final String occurTime;// 交易发生时间
    private final boolean status;// 交易状态

    public Transaction(String account, String occurTime, String type, double amount, double balance, boolean status) {
        super();
        this.account = account;
        this.type = type;
        this.amount = amount;
        this.balance = balance;
        this.occurTime = occurTime;
        this.status = status;
    }

    // 模拟用下标访问对象的每个属性值
    public Object get(int i) {
        Object retuval = null;
        switch (i) {
            case 0:
                retuval = this.account;
                break;
            case 1:
                retuval = this.type;
                break;
            case 2:
                retuval = this.amount;
                break;
            case 3:
                retuval = this.balance;
                break;
            case 4:
                retuval = this.occurTime;
                break;
            case 5:
                retuval = this.status;
                break;
            default:
                retuval = null;
        }
        return retuval;
    }
//添加必要的构造方法、每个属性的getter和setter方法以及其它方法。
}